﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MINERP.BLL.Statistics;
using MINERP.ComControls.Extension;
using MINERP.MODEL.FoundationModel;
using MINERP.COM;

namespace MINERP.Statistics.Forms.ProfessionalReports
{
    public partial class FrmsShopPrintStatis : Form
    {
        public FrmsShopPrintStatis()
        {
            InitializeComponent();
        }

        private static FrmsShopPrintStatis _instance;
        public static FrmsShopPrintStatis GetInstance
        {
            get
            {
                if (_instance == null || _instance.IsDisposed)
                {
                    _instance = new FrmsShopPrintStatis();
                }
                return _instance;
            }
        }
        BillIndexBLL2 _bllIndel2 = new BillIndexBLL2();
        private void textEditHelpCode_KeyDown(object sender, KeyEventArgs e)
        {
            if (Keys.Enter == e.KeyCode)
            {
                cbShop.DisplayMember = "ShopName";
                cbShop.ValueMember = "ShopId";
                cbShop.DataSource = _bllIndel2.GetShopInfoByHelpCode(textEditHelpCode.Text.Trim());


            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            //DateTime dateStart = dateTimePickerStartDate.Value.Date;
            //DateTime dateEnd = dateTimePickerEndDate.Value.Date;
            DateTime dateStart = dateTimePickerStartDate.Value.Date;
            DateTime dateEnd = dateTimePickerEndDate.Value.AddDays(1).Date.AddSeconds(-1);
            Shop_Info info = (Shop_Info)cbShop.SelectedItem;
            if (info != null)
            {

                gridControlBillIndex.DataSource = _bllIndel2.GetAllShopPrint(dateStart, dateEnd, info.ShopId).Tables[0];
                gridControlBillIndex.RefreshDataSource();
            }
            else
            {
                MessageBox.Show("请选择商户");
            }
        }

        private void FrmsShopPrintStatis_Load(object sender, EventArgs e)
        {

        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            Shop_Info info = (Shop_Info)cbShop.SelectedItem;
            if (info != null)
            {

                //DevGridViewExport.ExportToExcel(info.ShopName+"输出", gridViewBillIndex);

                DevControlExtension.ExportToExcel(gridControlBillIndex,this,info.ShopName+"输出");
            }
            else
            {
                MessageBox.Show("请选择商户");
            }
        }

    }
}
